﻿using Microsoft.AspNetCore.Http;
using Service.Domain.Entities;
using Service.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service.Application.Middlewares
{
    public class JwtResolverMiddleware
    {
        private readonly RequestDelegate _next;

        public JwtResolverMiddleware(RequestDelegate next)
        {
            this._next = next;
        }

        public void Invoke(HttpContext context, ICacheManager cacheManager)
        {
            //string jwtString = this.GetAndValidateAuthorizationHeader(context);

            // 解析jwt对象
            //var result = jwtHelper.ReadJwtToken(jwtString);

            //this.ValidateJwtExpired(result);

            //var user = cacheManager.Get<User>($"{jwtHelper.JwtUserCacheName}_{result.UserId}");

            //this.ValidateUser(user);

            this._next(context);
        }
    }
}
